﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CalcDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.Write("请输入数字A：");
                string strNumA = Console.ReadLine();
                Console.Write("请输入运算符(+、-、*、/)：");
                string strNumOperate = Console.ReadLine();
                Console.Write("请输入数字B：");
                string strNumB = Console.ReadLine();

                //工厂就是实例化出合适的对象，通过多态返回父类的方式
                Operation oper = null;
                oper = OperationFactory.CrateOperation(strNumOperate);
                oper.NumberA = Convert.ToInt32(strNumA);
                oper.NumberB = Convert.ToInt32(strNumB);
                double result = oper.GetResult();
                Console.Write("结果是：" + result.ToString());
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("您的输入有错："+ex.Message);
            }
        }
    }
}
